/**
 * 智能代付单笔付款接口
 *
 * @author xiezz
 * @version 1.1.2
 */
package org.com.yz.common.core;

import org.com.yz.common.config.ConfigureTest;
import org.com.yz.common.config.IPostService;
import org.com.yz.common.config.SignAlgorithm;
import org.com.yz.common.util.CacheUtil;
import org.com.yz.common.util.DateUtil;
import org.com.yz.common.util.Signature;
import org.com.yz.dal.dao.model.MchConfig;

import java.util.Map;

public class PyPay extends IPostService {

    private static final String SERVICE_NAME = "cib.epay.payment.pay";
    private static final String SERVICE_VER = "02";
    private static final String SERVICE_CUR = "CNY";

    @Override
    public String exec(Map<String, String> params,String mchNo) {
        MchConfig config = CacheUtil.me().getMchConfigInfo(mchNo,"");
//        CacheUtil cacheUtil = new CacheUtil();
//        String str = cacheUtil.getMchConfigInfo(mchNo);

        //String appId = CacheUtil.me().getMchConfigInfo(mchNo);
        //MchConfig config = new MchConfig();
        params.put("appid", config.getApp_id());
        params.put("service", SERVICE_NAME);
        params.put("ver", SERVICE_VER);
        params.put("sub_mrch", config.getSecond_accnt_name());
        params.put("cur", SERVICE_CUR);
        params.put("timestamp", DateUtil.getSeqString());
        params.put("sign_type", SignAlgorithm.get(SERVICE_NAME));
        params.put("mac", Signature.generateMAC(params,mchNo));

        return txn(ConfigureTest.isDevEnv() ? ConfigureTest.PY_DEV_API : ConfigureTest.PY_PROD_API, params,mchNo);
    }
}
